//
//  CartManager.swift
//  iOSProjectExtensionSwift
//
//  Created by HBGG on 2020/7/14.
//  Copyright © 2020 lidianchao. All rights reserved.
//

import UIKit
import Alamofire
class CartGoodsItem: NSObject {
    var goodsId = String()
    var goodsName = String()
    var goodsDescript = String()
    var price = String()
    var iconUrl = String()
    var goodsCount = String()
    var areaStr = String()
}

class CartListItem: NSObject {
    var shopName = String()
    var allGoods = Array<CartGoodsItem>()
}

class CartManager: BaseManager {
    private static let instance = CartManager()
    class func sharedManager() ->CartManager {
        return instance
    }
    func getAllGoodsInCart(callback:(_ result:Result,_ allGoods:Array<Any>) ->()) {
        var shopArr = Array<Any>()
        for _ in 1...10 {
            let cartListItem = CartListItem()
            cartListItem.shopName = "店铺"
            var goodsArr = Array<CartGoodsItem>()
            
            for _ in 1...10 {
                let goodsItem = CartGoodsItem()
                goodsItem.goodsId = "1"
                goodsItem.goodsName = "商品"
                goodsItem.goodsDescript = "描述"
                goodsItem.price = "价格"
                goodsItem.iconUrl = "https://ss0.bdstatic.com/94oJfD_bAAcT8t7mm9GUKT-xh_/timg?image&quality=100&size=b4000_4000&sec=1594712203&di=c0cf0987d58fd27ec7913da98854a020&src=http://a1.att.hudong.com/05/00/01300000194285122188000535877.jpg"
                goodsItem.goodsCount = "11"
                goodsItem.areaStr = "河北"
                goodsArr.append(goodsItem)
            }
            cartListItem.allGoods = goodsArr
            shopArr.append(cartListItem)
        }
        
        let parameters:Dictionary = ["key":"93c921ea8b0348af8e8e7a6a273c41bd"]
        Alamofire.request("http://apis.haoservice.com/weather/city",parameters:parameters ).responseJSON { (response) in
            print(response)
        }
        
        
        callback(Result.Result_OK,shopArr)
    }
}
